﻿@{
	string FlowID = Request.QueryString["flowid"];
	string StepID = Request.QueryString["stepid"];
	string GroupID = Request.QueryString["groupid"];
	string TaskID = Request.QueryString["taskid"];
	string InstanceID = Request.QueryString["instanceid"];
	string DisplayModel = Request.QueryString["display"] ?? "0";
	string DBConnID = "06075250-30dc-4d32-bf97-e922cb30fac8";
	string DBTable = "OaLeave";
	string DBTablePK = "ID";
	string DBTableTitle = "";
	if(InstanceID.IsNullOrEmpty()){InstanceID = Request.QueryString["instanceid1"];}
	YJ.Platform.Dictionary BDictionary = new YJ.Platform.Dictionary();
	YJ.Platform.WorkFlow BWorkFlow = new YJ.Platform.WorkFlow();
	YJ.Platform.WorkFlowTask BWorkFlowTask = new YJ.Platform.WorkFlowTask();
	string fieldStatus = BWorkFlow.GetFieldStatus(FlowID, StepID);
	LitJson.JsonData initData = BWorkFlow.GetFormData(DBConnID, DBTable, DBTablePK, InstanceID, fieldStatus, "{\"oaleave.leavedate\":\"yyyy年MM月dd日\",\"oaleave.starttime\":\"yyyy-MM-dd\",\"oaleave.starttimehr\":\"HH:mm \",\"oaleave.endtime\":\"yyyy-MM-dd\",\"oaleave.endtimehr\":\"HH:mm \"}");
	string TaskTitle = BWorkFlow.GetFromFieldData(initData, DBTable, DBTableTitle);
}
<link href="~/Scripts/FlowRun/Forms/flowform.css" rel="stylesheet" type="text/css" />
<script src="~/Scripts/FlowRun/Forms/common.js" type="text/javascript" ></script>
<input type="hidden" id="Form_ValidateAlertType" name="Form_ValidateAlertType" value="1" />
<input type="hidden" id="OaLeave." name="OaLeave." value="@(TaskTitle.IsNullOrEmpty() ? BWorkFlow.GetAutoTaskTitle(FlowID, StepID, Request.QueryString["groupid"]) : TaskTitle)" />
<input type="hidden" id="Form_TitleField" name="Form_TitleField" value="OaLeave." />
<input type="hidden" id="Form_DBConnID" name="Form_DBConnID" value="06075250-30dc-4d32-bf97-e922cb30fac8" />
<input type="hidden" id="Form_DBTable" name="Form_DBTable" value="OaLeave" />
<input type="hidden" id="Form_DBTablePk" name="Form_DBTablePk" value="ID" />
<input type="hidden" id="Form_DBTableTitle" name="Form_DBTableTitle" value="" />
<input type="hidden" id="Form_AutoSaveData" name="Form_AutoSaveData" value="1" />
<textarea id="Form_DBTableTitleExpression" name="Form_DBTableTitleExpression" style="display:none;width:0;height:0;"></textarea>
<script type="text/javascript">
	var initData = @Html.Raw(BWorkFlow.GetFormDataJsonString(initData));
	var fieldStatus = "1"=="@Request.QueryString["isreadonly"]" ? {} : @Html.Raw(fieldStatus);
	var displayModel = '@DisplayModel';
	$(window).load(function (){
		formrun.initData(initData, "OaLeave", fieldStatus, displayModel);
	});
</script>
<script type="text/javascript">
	var day = 0;
	$(function() {
		clickday();
	});

	function checkdate(type) {
		try {
			if(type == 0) {
                var userID = document.getElementById("lky").value;
				var url = "/PlatformApi/OaDailyOffice/GetDay?type=0&UserID="+userID+"";
				$.ajax({
					url: url,
					contentType: "application/json",
					type: "GET",
					dataType: "json",
					cache: false,
					async: false,
					success: function(json) {
						if(json.status == 0) {
							$("input[type='radio']").removeAttr('checked');
							day = 1;
							alert(json.msg);
						} else {
							alert(json.msg);
						}
					},
					error: function(json) {
						RoadUI.Core.showError(json);
					}
				});
			} else {
				var statedate = document.getElementById("OaLeave.StartTime").value;
				var statedatehr = document.getElementById("OaLeave.StartTimeHr").value;
				var enddate = document.getElementById("OaLeave.EndTime").value;
				var enddatehr = document.getElementById("OaLeave.EndTimeHr").value;
				var url = "/PlatformApi/OaDailyOffice/GetDay?type=1&statedate=" + statedate + "&enddate=" + enddate + "&statedatehr=" + statedatehr + "&enddatehr=" + enddatehr;
				$.ajax({
					url: url,
					contentType: "application/json",
					type: "GET",
					dataType: "json",
					async: false,
					success: function(json) {
						if(json.status == 1) {
							document.getElementById("OaLeave.Days").value = json.data;
                          var hous=0;
                          if(enddatehr=='17:30'){
                            hous=0.5;
                          }
							document.getElementById("OaLeave.Hours").value = json.Hours+hous;
						} else {
							document.getElementById("OaLeave.Days").value = 0;
							document.getElementById("OaLeave.Hours").value = 0;
							//alert(json.msg); 
						}
					},
					error: function(json) {
						RoadUI.Core.showError(json);
					}
				});

			}

		} catch(e) {
			alert(e.message);
		}
	}

	function clickday() {
		try {
			var type = $("input[type='radio']:checked").val();
			if(type == 6) {
				checkdate(1);
			} else {
				var statedate = document.getElementById("OaLeave.StartTime").value;
				var statedatehr = document.getElementById("OaLeave.StartTimeHr").value;
				var enddate = document.getElementById("OaLeave.EndTime").value;
				var enddatehr = document.getElementById("OaLeave.EndTimeHr").value;
				var url = "/PlatformApi/OaDailyOffice/GetWorkDay?statedate=" + statedate + "&enddate=" + enddate + "&statedatehr=" + statedatehr + "&enddatehr=" + enddatehr;
				$.ajax({
					url: url,
					contentType: "application/json",
					type: "GET",
					dataType: "json",
					async: false,
					success: function(json) {
						if(json.status == 1) {
							document.getElementById("OaLeave.Days").value = json.data;
							document.getElementById("OaLeave.Hours").value = json.Hours;
						} else {
							document.getElementById("OaLeave.Days").value = 0;
							document.getElementById("OaLeave.Hours").value = 0;
						}
					},
					error: function(json) {
						RoadUI.Core.showError(json);
					}
				});
			}
		} catch(e) {
			alert(e.message);
		}
	}</script><p><input type="hidden" id="OaLeave.op" name="OaLeave.op" isflow="1" type1="flow_hidden" value="u_@(new YJ.Platform.WorkFlowTask().GetFirstSnderID(FlowID.ToGuid(), GroupID.ToGuid(), true))"/><input type="hidden" id="lky" name="lky" isflow="1" type1="flow_hidden" value="u_@YJ.Platform.Users.CurrentUserID.ToString()"/></p><p><br/></p><p><br/></p><table class="flowformtable tableF table table-bordered" data-sort="sortDisabled" cellspacing="0" cellpadding="0" align="center"><tbody><tr class="firstRow"><th rowspan="1" colspan="2" valign="middle" align="center"><span class="title">请 假 申 请</span></th></tr><tr><th class="titleT" rowspan="1" colspan="2" valign="middle" align="left"><p class="titleO">基本信息</p></th></tr><tr class="topTr"><td class="top" rowspan="1" colspan="1" valign="middle" align="left"><p class="txt">姓名</p><input type="text" type1="flow_org" id="OaLeave.UserID" name="OaLeave.UserID" value="u_@YJ.Platform.Users.CurrentUserID.ToString()" style="width:55%" more="0" isflow="1" class="mymember" title="" dept="0" station="0" user="1" workgroup="0" unit="0" rootid="04f12beb-d99d-43df-ac9a-3042957d6bda"/></td><td class="top" rowspan="1" colspan="1" valign="middle" align="left"><p class="txt">部门</p><input type="text" type1="flow_org" id="OaLeave.DeptName" name="OaLeave.DeptName" value="@(new YJ.Platform.WorkFlowTask().GetFirstSnderDeptID(FlowID.ToGuid(), GroupID.ToGuid()))" style="width:55%" more="0" isflow="1" class="mymember" title="" dept="1" station="0" user="0" workgroup="0" unit="0" rootid="04f12beb-d99d-43df-ac9a-3042957d6bda"/></td></tr><tr class="bottomTr"><td class="bottom" rowspan="1" colspan="1" valign="middle" align="left"><p class="txt">申请日期</p><input type="text" type1="flow_datetime" id="OaLeave.LeaveDate" name="OaLeave.LeaveDate" value="@(YJ.Utility.DateTimeNew.ShortDate)" format="yyyy年MM月dd日" defaultvalue="%40(YJ.Utility.DateTimeNew.ShortDate)" istime="0" daybefor="0" dayafter="0" currentmonth="0" isflow="1" class="mycalendar" title=""/></td><td class="bottom" rowspan="1" colspan="1" valign="middle" align="left"><p class="txt">申请人公司</p><input type="text" type1="flow_org" id="OaLeave.Unit" name="OaLeave.Unit" value="@(YJ.Platform.Users.CurrentUnitID)" style="width:55%" more="0" isflow="1" class="mymember" title="" dept="1" station="0" user="0" workgroup="0" unit="1" rootid="04f12beb-d99d-43df-ac9a-3042957d6bda"/></td></tr><tr><th class="titleT" rowspan="1" colspan="2" valign="middle" align="left"><p class="titleO">基本信息</p></th></tr><tr class="topTr"><td class="Tradio top" rowspan="1" colspan="2" valign="middle" align="left"><p class="txt">请假类型</p><input type="radio" name="OaLeave.Type" id="OaLeave.Type_0" value="1" style="vertical-align:middle;" isflow="1" type1="flow_radio" onclick="onclick_0b306519094cce7c441984f0d674da1a(this);"/><label for="OaLeave.Type_0" style="vertical-align:middle;margin-right:3px;">事假</label><input type="radio" name="OaLeave.Type" id="OaLeave.Type_1" value="2" style="vertical-align:middle;" isflow="1" type1="flow_radio" onclick="onclick_0b306519094cce7c441984f0d674da1a(this);"/><label for="OaLeave.Type_1" style="vertical-align:middle;margin-right:3px;">病假</label><input type="radio" name="OaLeave.Type" id="OaLeave.Type_2" value="3" style="vertical-align:middle;" isflow="1" type1="flow_radio" onclick="onclick_0b306519094cce7c441984f0d674da1a(this);"/><label for="OaLeave.Type_2" style="vertical-align:middle;margin-right:3px;">婚、丧假</label><input type="radio" name="OaLeave.Type" id="OaLeave.Type_3" value="4" style="vertical-align:middle;" isflow="1" type1="flow_radio" onclick="onclick_0b306519094cce7c441984f0d674da1a(this);"/><label for="OaLeave.Type_3" style="vertical-align:middle;margin-right:3px;">产假</label><input type="radio" name="OaLeave.Type" id="OaLeave.Type_4" value="5" style="vertical-align:middle;" isflow="1" type1="flow_radio" onclick="onclick_0b306519094cce7c441984f0d674da1a(this);"/><label for="OaLeave.Type_4" style="vertical-align:middle;margin-right:3px;">护理假</label><input type="radio" name="OaLeave.Type" id="OaLeave.Type_5" value="6" style="vertical-align:middle;" isflow="1" type1="flow_radio" onclick="onclick_0b306519094cce7c441984f0d674da1a(this);"/><label for="OaLeave.Type_5" style="vertical-align:middle;margin-right:3px;">调休</label><script type="text/javascript">function onclick_0b306519094cce7c441984f0d674da1a(srcObj){var type=$("input[type='radio']:checked").val();
if(type==6){
checkdate(0);}}</script></td></tr><tr><td rowspan="1" colspan="1" valign="middle" align="left"><p class="txt">起始日期</p><input type="text" type1="flow_datetime" id="OaLeave.StartTime" name="OaLeave.StartTime" value="@(YJ.Utility.DateTimeNew.ShortDate)" format="yyyy-MM-dd" defaultvalue="%40(YJ.Utility.DateTimeNew.ShortDate)" istime="1" daybefor="0" dayafter="0" currentmonth="0" isflow="1" class="mycalendar" title="" onchange="onchange_93bb2f3be3376b178d6b9fd9d0d749dc (this);"/><script type="text/javascript">function onchange_93bb2f3be3376b178d6b9fd9d0d749dc(srcObj){clickday();}</script></td><td rowspan="1" colspan="1" valign="middle" align="left"><p class="txt">起始时间</p><input type="text" type1="flow_datetime" id="OaLeave.StartTimeHr" name="OaLeave.StartTimeHr" value="08:30" format="HH:mm " defaultvalue="08%3A30" istime="1" daybefor="0" dayafter="0" currentmonth="0" isflow="1" class="mycalendar" title="" onblur="onblur_ddaa0ecbec8ddebb88b975e26a601ab1 (this);"/><script type="text/javascript">function onblur_ddaa0ecbec8ddebb88b975e26a601ab1(srcObj){clickday();}</script></td></tr><tr><td rowspan="1" colspan="1" valign="middle" align="left"><p class="txt">结束日期</p><input type="text" type1="flow_datetime" id="OaLeave.EndTime" name="OaLeave.EndTime" value="@(YJ.Utility.DateTimeNew.ShortDate)" format="yyyy-MM-dd" defaultvalue="%40(YJ.Utility.DateTimeNew.ShortDate)" istime="1" daybefor="0" dayafter="0" currentmonth="0" isflow="1" class="mycalendar" title="" onchange="onchange_f75c92ca9546cb90c095d701a4d8f9a8 (this);"/><script type="text/javascript">function onchange_f75c92ca9546cb90c095d701a4d8f9a8(srcObj){clickday();}</script></td><td rowspan="1" colspan="1" valign="middle" align="left"><p class="txt">结束时间</p><input type="text" type1="flow_datetime" id="OaLeave.EndTimeHr" name="OaLeave.EndTimeHr" value="17:00" format="HH:mm " defaultvalue="17%3A00" istime="1" daybefor="0" dayafter="0" currentmonth="0" isflow="1" class="mycalendar" title="" onblur="onblur_5c9e5244494e47a31cd7a4129ba3c7cd (this);"/><script type="text/javascript">function onblur_5c9e5244494e47a31cd7a4129ba3c7cd(srcObj){clickday();}</script></td></tr><tr><td rowspan="1" colspan="2" valign="middle" align="left"><p class="txt">请假天数</p><input type="text" id="OaLeave.Days" type1="flow_text" name="OaLeave.Days" value="" placeholder="请假天数" style="width:15%;text-align:left;padding-right:3px;" valuetype="4" isflow="1" class="mytext" title="" align="left"/>天<input type="text" id="OaLeave.Hours" type1="flow_text" name="OaLeave.Hours" value="" placeholder="请假小时数" style="width:15%;text-align:left;padding-right:3px;" valuetype="4" isflow="1" class="mytext" title="" align="left"/>小时</td></tr><tr class="bottomTr"><td class="bottom" rowspan="1" colspan="2" valign="middle" align="left"><p class="txt">请假原因</p><textarea isflow="1" type1="flow_textarea" id="OaLeave.Reason" name="OaLeave.Reason" class="mytext" style="height:40px;"></textarea></td></tr></tbody></table>